<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class NotificationResource extends JsonResource
{
    public function toArray($request)
    {
    	$resource = $this->resource;
    	
        return [
        	'id' => (int)$resource->id,
	        'type' => $resource->type,
	        'data' => $resource->data,
	        'read_at' => (string)$resource->read_at ?: null,
	        'created_at' => (string)$resource->created_at,
	        'human_created_at' => $resource->created_at->diffForHumans()
        ];
    }
}
